package com.gitee.deament.server.core.data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Objects;


/**
 * 有序集合数据结构
 * @author  deament
 */
public class ZSortSetMember implements Serializable,Comparable<ZSortSetMember>{
    public ZSortSetMember(BigDecimal score, String member) {
        this.score = score;
        this.member = member;
    }

    private BigDecimal score;
    private String member;

    public BigDecimal getScore() {
        return score;
    }

    public void setScore(BigDecimal score) {
        this.score = score;
    }

    public String getMember() {
        return member;
    }

    public void setMember(String member) {
        this.member = member;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ZSortSetMember zSortSet = (ZSortSetMember) o;
        return Objects.equals(score, zSortSet.score) &&
                Objects.equals(member, zSortSet.member);
    }

    @Override
    public int hashCode() {
        return Objects.hash(score, member);
    }

    @Override
    public int compareTo(ZSortSetMember other) {
        if(this.getScore().compareTo(other.getScore())>0){
            return 1;
        }
        if(this.getScore().compareTo(other.getScore())<0){
            return -1;
        }
        return 0;
    }
}
